/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.session;

import com.thienloc.omap.entity.TinhCauRs;
import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author GiangLT
 */
@Stateless
public class TinhCauRsFacade extends AbstractFacade<TinhCauRs> {

    @PersistenceContext(unitName = "omapPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TinhCauRsFacade() {
        super(TinhCauRs.class);
    }

    public void tinhCau(Integer number) throws Exception {
        try {
            Query q = em.createNativeQuery("{call TINH_CAU_TMP(?)}");

            q.setParameter(1, number);
            q.executeUpdate();
        } catch (Exception ex) {
            LoggerFactory.getLogger(TinhCauRsFacade.class.getName()).error("", ex);
            throw ex;
        }
    }
}
